<ol class="breadcrumb">
  <li>
    <a class="badge badge-type" href="#">Master</a>
  </li>
  <li>
    <a class="badge badge-type" href="#/slaves/{{slave_id}}" title="{{slave_id}}">
      Slave</a>
  </li>
  <li class="active">
    Browse
  </li>
</ol>

<ol class="breadcrumb">
  <li ng-repeat="dir in path.split('/')">
    <a href="#/slaves/{{slave_id}}/browse?path={{
             encodeURIComponent(path.split('/').slice(0, $index + 1).join('/'))}}">
      {{dir}}
    </a>
  </li>
</ol>

<div class="alert alert-error hide" id="alert">
  <button class="close" data-dismiss="alert">×</button>
  <strong>{{alert_message}}</strong>
</div>

<div class="row" id="listing">
  <div class="col-md-9">
    <div class="well">
      <div data-ng-show="listing.length == 0">
        No files in this directory.
      </div>
      <table class="table table-condensed" data-ng-show="listing.length > 0">
        <thead>
          <tr>
            <th>mode</th>
            <th class="text-right">nlink</th>
            <th>uid</th>
            <th>gid</th>
            <th class="text-right">size</th>
            <th class="text-right">mtime</th>
            <th></th>
            <th></th>
          </tr>
        </thead>
        <tbody>
          <tr ng-repeat="file in listing | orderBy:['-mode', 'path']">
            <td>{{file.mode}}</td>
            <td class="text-right">{{file.nlink}}</td>
            <td>{{file.uid}}</td>
            <td>{{file.gid}}</td>
            <td class="text-right">{{file.size | dataSize}}</td>
            <td class="text-right">{{file.mtime * 1000 | unixDate}}</td>
            <td>
              <span data-ng-show="file.mode[0] == 'd'">
                <i class="glyphicon glyphicon-folder-close"></i>
                <a href="#/slaves/{{slave_id}}/browse?path={{encodeURIComponent(file.path)}}">
                  {{basename(file.path)}}
                </a>
              </span>
              <span data-ng-show="file.mode[0] != 'd'">
                <i class="glyphicon glyphicon-file" style="visibility: hidden;"></i>
                <a href="" ng-click="pail($event, encodeURIComponent(file.path))">
                  {{basename(file.path)}}
                </a>
              </span>
            </td>
            <td>
              <a data-ng-show="file.mode[0] != 'd'"
                 href="http://{{slave_host}}/files/download.json?path={{encodeURIComponent(file.path)}}">
                <button class="btn btn-xs btn-default" type="button">
                  Download
                </button>
              </a>
            </td>
          </tr>
        </tbody>
      </table>
    </div>
  </div>
</div>
